# coding:utf-8
import uuid
from datetime import datetime
from peewee import CharField, DateTimeField, IntegerField, UUIDField

from . import db


def get_curr_datetime():
    # DateTimeField的默认有坑……   要么用Timestamp
    date = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
    return datetime.strptime(date, '%Y-%m-%d %H:%M:%S.%f')


class Item(db.Model):
    rowid = UUIDField(primary_key=True, default=uuid.uuid4)
    number = CharField(max_length=255)
    name = CharField(max_length=255)
    create_time = DateTimeField(default=get_curr_datetime)
    status = IntegerField(default=0, null=False)  # 0: 在库  1: 借出
